import fetch from '@/utils/request'

/**
 * Material service
 */
const Material = {
	prepare: (material, scene) => fetch.request({
		url: "/api/user/material/upload/prepare",
		method: "POST",
		data: {
			material: material,
			useChunk: false,
			scene: scene
		}
	}),
	confirm: material => fetch.request({
		url: "/api/user/material/upload/confirm",
		method: "POST",
		data: {
			material: material
		}
	}),
	preview: (id) => fetch.request({
		url: "/api/user/material/preview",
		method: "POST",
		data: {
			id: id
		}
	}),
	path: (query) => fetch.request({
		url: '/api/user/material/path',
		data: {
			query: query,
		},
		method: 'post'
	}),
	folder: (folder) => fetch.request({
		url: '/api/user/material/folder',
		data: {
			material: folder,
		},
		method: 'POST'
	}),
	page: (query, param) => fetch.request({
		url: '/api/user/material/query',
		data: {
			query: query,
			param: param
		},
		method: 'POST'
	}),
	download: url => fetch.request({
		baseURL: '',
		url: url,
		method: 'POST',
		responseType: 'blob',
	}),
};

export default Material
